package com.example.provider.controller;

import api.TestApi;
import bean.request.TestDto;
import bean.response.TestVo;
import com.example.provider.aop.TestBefore;
import com.example.provider.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Description
 *
 * @author zhuwenqiang
 * @data
 */

@RestController
public class TestController implements TestApi {

    @Autowired
    private TestService testService;


    @Override
    public String add(@RequestBody TestDto testDto) {
        int add = testService.add(testDto);
        String res = "插入成功";
        if (add<1){
            res = "插入失败";
        }
        return res;
    }

    @Override
    public TestVo search(TestDto testDto) {
        return testService.search(testDto);
    }

    @Override
    @TestBefore(testInt = 1)
    public TestVo testAop(TestDto testDto) {

        return null;
    }

    @ResponseBody
    @RequestMapping(value = "test",method = RequestMethod.GET)
    public String test(){
        return "hello";
    }
}
